package com.lcxw.hxzbadmin.dao.configmapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;
import com.lcxw.hxzbadmin.entity.configbean.CacheConfig;
import com.lcxw.hxzbadmin.entity.configbean.LiveConfig;
import com.lcxw.hxzbadmin.entity.configbean.RegisterConfig;
import com.lcxw.hxzbadmin.entity.configbean.SEOConfig;
import com.lcxw.hxzbadmin.entity.configbean.ShareConfig;
import com.lcxw.hxzbadmin.entity.configbean.YwpdBaseConfig;

/**
 * @author Administrator
 */
@Mapper
@Component
public interface BaseConfigMapper {

    //修改基本配置
    @Update({
        "update ywpd_baseconfig",
        "set `closeSite` = #{closeSite},",
        "`closeTip` = #{closeTip,jdbcType=VARCHAR},",
        "`logo` = #{logo,jdbcType=VARCHAR},",
        "`siteName` = #{siteName,jdbcType=VARCHAR},",
        "`siteTitle` = #{siteTitle,jdbcType=VARCHAR},",
        "`siteUrl` = #{siteUrl,jdbcType=VARCHAR},",
        "`siteDomain` = #{siteDomain,jdbcType=VARCHAR},",
        "`copyright` = #{copyright,jdbcType=VARCHAR}",
        "where `id` = 1"
    })
    int updateBaseConfigByPrimaryKey(YwpdBaseConfig record)throws Exception;

    //查询基本配置
    @Select("select id,closeSite,closeTip,logo,siteName,siteTitle,siteUrl,siteDomain,copyright from ywpd_baseconfig where `id` = 1")
    YwpdBaseConfig selectBaseConfigByPrimaryKey() throws Exception;

    //修改SEO相关设置
    @Update({
        "update ywpd_baseconfig",
        "set `titleSuffix` = #{titleSuffix},",
        "`META` = #{META},",
        "`METAdesc` = #{METAdesc}",
        "where `id` = 1"
    })
    int updateSEOConfigByPrimaryKey(SEOConfig record)throws Exception;

    //查询SEO相关设置
    @Select("select titleSuffix,META,METAdesc from ywpd_baseconfig where `id` = 1")
    SEOConfig selectSEOConfigByPrimaryKey() throws Exception;

    //修改注册相关设置
    @Update({
        "update ywpd_baseconfig",
        "set `allowReg` = #{allowReg},",
        "`needCheck` = #{needCheck},",
        "`forbidden` = #{forbidden},",
        "`ucUrl` = #{ucUrl} ",
        "where `id` = 1"
    })
    int updateRegisterConfigByPrimaryKey(RegisterConfig record)throws Exception;

    //查询注册相关设置
    @Select("select allowReg,needCheck,forbidden,UCurl from ywpd_baseconfig where `id` = 1")
    RegisterConfig selectRegisterConfigByPrimaryKey() throws Exception;

    //修改直播相关设置
    @Update({
        "update ywpd_baseconfig",
        "set `liveAccess` = #{liveAccess},",
        "`ratio` = #{ratio},",
        "`cdn` = #{cdn},",
        "`cdnPullUrl` = #{cdnPullUrl},",
        "`fps` = #{fps},",
        "`maxBit` = #{maxBit},",
        "`quality` = #{quality},",
        "`frame` = #{frame},",
        "`resolutionWidth` = #{resolutionWidth},",
        "`resolutionHeight` = #{resolutionHeight} ",
        "where `id` = 1"
    })
    int updateLiveConfigByPrimaryKey(LiveConfig record)throws Exception;

    //查询直播相关设置
    @Select("select liveAccess,ratio,cdn,cdnPullUrl,fps,maxBit,quality,frame,resolutionWidth,resolutionHeight from ywpd_baseconfig where `id` = 1")
    LiveConfig selectLiveConfigByPrimaryKey() throws Exception;

    //修改缓存机制配置参数
    @Update({
        "update ywpd_baseconfig",
        "set `cacheEnable` = #{cacheEnable},",
        "`cacheTime` = #{cacheTime},",
        "`cacheType` = #{cacheType},",
        "`cacheSuffix` = #{cacheSuffix}",
        "where `id` = 1"
    })
    int updateCacheConfigByPrimaryKey(CacheConfig record)throws Exception;

    //查询缓存相关设置
    @Select("select cacheEnable,cacheTime,cacheType,cacheSuffix from ywpd_baseconfig where `id` = 1")
    CacheConfig selectCacheConfigByPrimaryKey() throws Exception;

    //修改收入分成配置参数
    @Update({
        "update ywpd_baseconfig",
        "set `anchor` = #{anchor},",
        "`anchorAgent` = #{anchorAgent},",
        "`chargeAgent` = #{chargeAgent} ",
        "where `id` = 1"
    })
    int updateShareConfigByPrimaryKey(ShareConfig record)throws Exception;

    //查询收入分成设置
    @Select("select anchor,anchorAgent,chargeAgent from ywpd_baseconfig where `id` = 1")
    ShareConfig selectShareConfigByPrimaryKey() throws Exception;
}
